// @ts-ignore
/* eslint-disable */
import request from '@/utils/request'

/** 此处后端没有提供注释 POST /file/checkChunk */
export async function checkChunk(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: MediaService.checkChunkParams,
  options?: { [key: string]: any }
) {
  return request<MediaService.ResultBoolean>(`/media/file/checkChunk`, {
    method: 'POST',
    params: {
      ...params,
    },
    ...(options || {}),
  })
}

/** 此处后端没有提供注释 POST /file/checkFile */
export async function checkFile(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: MediaService.checkFileParams,
  options?: { [key: string]: any }
) {
  return request<MediaService.ResultBoolean>(`/media/file/checkFile`, {
    method: 'POST',
    params: {
      ...params,
    },
    ...(options || {}),
  })
}

/** 此处后端没有提供注释 POST /file/deleteFile */
export async function deleteFile(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: MediaService.deleteFileParams,
  options?: { [key: string]: any }
) {
  return request<MediaService.ResultBoolean>(`/media/file/deleteFile`, {
    method: 'POST',
    params: {
      ...params,
    },
    ...(options || {}),
  })
}

/** 合并文件 合并文件 POST /file/mergeChunks */
export async function mergeChunks(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: MediaService.mergeChunksParams,
  options?: { [key: string]: any }
) {
  return request<MediaService.Result>(`/media/file/mergeChunks`, {
    method: 'POST',
    params: {
      ...params,
    },
    ...(options || {}),
  })
}

/** 此处后端没有提供注释 POST /file/uploadChunk */
export async function uploadChunk(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: MediaService.uploadChunkParams,
  body: {},
  file?: File,
  options?: { [key: string]: any }
) {
  const formData = new FormData()

  if (file) {
    formData.append('file', file)
  }

  Object.keys(body).forEach((ele) => {
    const item = (body as any)[ele]

    if (item !== undefined && item !== null) {
      if (typeof item === 'object' && !(item instanceof File)) {
        if (item instanceof Array) {
          item.forEach((f) => formData.append(ele, f || ''))
        } else {
          formData.append(ele, JSON.stringify(item))
        }
      } else {
        formData.append(ele, item)
      }
    }
  })

  return request<MediaService.Result>(`/media/file/uploadChunk`, {
    method: 'POST',
    params: {
      ...params,
    },
    data: formData,
    ...(options || {}),
  })
}

/** 此处后端没有提供注释 POST /file/uploadDoc */
export async function uploadDoc(body: {}, file?: File, options?: { [key: string]: any }) {
  const formData = new FormData()

  if (file) {
    formData.append('file', file)
  }

  Object.keys(body).forEach((ele) => {
    const item = (body as any)[ele]

    if (item !== undefined && item !== null) {
      if (typeof item === 'object' && !(item instanceof File)) {
        if (item instanceof Array) {
          item.forEach((f) => formData.append(ele, f || ''))
        } else {
          formData.append(ele, JSON.stringify(item))
        }
      } else {
        formData.append(ele, item)
      }
    }
  })

  return request<MediaService.ResultUploadFileResultDto>(`/media/file/uploadDoc`, {
    method: 'POST',
    data: formData,
    ...(options || {}),
  })
}

/** 此处后端没有提供注释 POST /file/uploadPic */
export async function uploadPic(body: {}, file?: File, options?: { [key: string]: any }) {
  const formData = new FormData()

  if (file) {
    formData.append('file', file)
  }

  Object.keys(body).forEach((ele) => {
    const item = (body as any)[ele]

    if (item !== undefined && item !== null) {
      if (typeof item === 'object' && !(item instanceof File)) {
        if (item instanceof Array) {
          item.forEach((f) => formData.append(ele, f || ''))
        } else {
          formData.append(ele, JSON.stringify(item))
        }
      } else {
        formData.append(ele, item)
      }
    }
  })

  return request<MediaService.ResultUploadFileResultDto>(`/media/file/uploadPic`, {
    method: 'POST',
    data: formData,
    ...(options || {}),
  })
}
